/*
 Copyright 2008 Jason E. Smith Licensed under the Apache License, Version 2.0 (the "License"); 
 You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 */

Swf2 = namespace("controls::Swf2", {
    inherits: Widget,
	
    model: {
		src : "FABridge2.swf"
	},
	
    initialize: function(){	
		/*swfobject.addLoadEvent(function(){
			console.log("loaded document");
			this.flex = FABridge.flex;
		}.bind(this),false)*/
		this.swfLoadTimer = setInterval(this.isSwfLoader.bind(this), 500);
		swfobject.registerObject(this.element.firstChild, "9.0.0", "expressInstall.swf");
		
		return this;
    },	
	isSwfLoader : function(){
		if (FABridge.flex.root()) {
			clearInterval(this.swfLoadTimer);
			this.flex = FABridge.flex;
			console.log("Successfully established js <-> flex bridge")
		}
		else {
			console.log("loading swf...")
		}
	},
	
	render : function() { return this.element; },
	
	html:
	'<div>\
		<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="444" height="444" id="myid" name="myid">\
			<param name="movie" value="{ get("src") }" />\
			<param name="allowscriptaccess" value="always" />\
			<!--[if !IE]>-->\
			<object type="application/x-shockwave-flash" data="{get("src") }" width="444" height="444">\
				<param name="allowscriptaccess" value="always" />\
			<!--<![endif]-->\
				<a href="http://www.adobe.com/go/getflashplayer">\
					<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />\
				</a>\
			<!--[if !IE]>-->\
			</object>\
			<!--<![endif]-->\
		</object>\
	</div>'
})
